﻿using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace Loki.UI.Win
{
    public static class EditorExtensions
    {
        public static void BindValue<T>(this BaseEdit P_Editor, T P_Context, Expression<Func<T, object>> P_Property, DataSourceUpdateMode P_Mode = DataSourceUpdateMode.OnValidation, IValueConverter P_Converter = null, object P_ConverterParameter = null) where T : INotifyPropertyChanged
        {
            ViewBase L_Form = P_Editor.FindForm() as ViewBase;
            L_Form.DataBinder.TwoWay<BaseEdit, T>(P_Editor, e => e.EditValue, P_Context, P_Property, P_Mode, P_Converter, P_ConverterParameter);
        }

        public static void Configure(this RepositoryItemTextEdit P_Editor, string P_WaterMark)
        {
            P_Editor.NullText = P_WaterMark;
            //P_Editor
        }
    }
}
